﻿package core.ui.dialogs
{
    import core.enum.*;
    import core.event.*;
    import core.image.*;
    import core.ui.controls.*;

    public class BrightnessContrastDialog extends BitmapOperationDialogBase
    {
        var b:Slidebar;
        var c:Slidebar;

        public function BrightnessContrastDialog(param1:Tuyitu)
        {
            super(param1, "rm_brightness_contrast", 240, 180, Action.BrightnessContrastAdjustment);
            this.b = new Slidebar("rm_brightness", -100, 100, 200, 0);
            this.b.addEventListener(SliderEvent.DRAG, this.Change, false, 1, true);
            this.b.x = 20;
            this.b.y = 35;
            addChild(this.b);
            this.c = new Slidebar("rm_contrast", -100, 100, 200, 0);
            this.c.addEventListener(SliderEvent.DRAG, this.Change, false, 1, true);
            this.c.x = 20;
            this.c.y = 80;
            addChild(this.c);
            return;
        }// end function

        override public function Change(... args) : void
        {
            args = null;
            if (!locked)
            {
                args = new ColorMatrix();
                args.AdjustBrightness(this.b.value / 100 * 255);
                args.AdjustContrast(this.c.value / 100);
                bm.applyFilter(bc, bc.rect, bc.rect.topLeft, args.filter);
                Misc.ApplySelection(bm, bc, selection, offset);
            }
            return;
        }// end function

    }
}
